<!DOCTYPE HTML>
<html lang="utf-8">
<head>
<meta charset="utf-8">
<title>驾车宝典-发表活动</title>
<link href="${ctx}/styles/forum.css" rel="stylesheet" type="text/css">
<#include '/baseHead.ftl'>
<script type="text/javascript" src="${ctx}/scripts/My97DatePicker/WdatePicker.js"></script>s
<!--主要部分开始-->
<section id="main"><div class="bgA_01">
	
	<div class="breadcrumbPanel_01">
		<p>
		 <a href="/${ctx}" title="回到首页">首页</a> &gt;
				 <a href="<@forumList cityNo="${group.cityNo}" cateId="${group.fkCateId}" filter="0" titleTypeId="0" pageNumber="1" orderBy="1"  />" title="${group.cateName}">${group.cateName}</a> &gt; 
				 <span class="on"> <a href="<@groupDetailLink groupId="${group.groupId?c}" />" title="${group.groupName}">${group.groupName}</a>
		</p>
	</div>
	
	<div class="forumEditPanel_01">
		<div class="formField">
			<div class="formList">
			<form id="editorForm" action="${ctx}/topic/createtopic" method="post">
				<dl>
					<dt>活动标题：</dt>
					<dd>
							<input type="text" name="topicTitleBeforeFilter" id="topicTitleBeforeFilter" class="txt" placeholder="请输入标题,标题最大长度为30个中文字" onkeyup='calRemain();'>
							<span>还可输入 <strong id="remain">30</strong> 个字符</span>					
					</dd>
				</dl>
				<dl>
					<dt></dt>
					<dd>
						<input type="radio" class="radio" name="activityTypeRadio" id="activityTypeRadio" value="1" onclick='changeType();' checked>
						<label for="activityType_1">免费活动</label> 
						<!--
							<input type="radio" class="radio" name="activityTypeRadio" id="activityTypeRadio" value="2">
							<label for="activityType_2">付费活动</label>
						-->
						 <input type="radio" class="radio" name="activityTypeRadio" id="activityTypeRadio" value="3" onclick='changeType();'>
						 <label for="activityType_3">需消耗正能量</label>
						  <input type='text' name='point' id='point'  style="width:30px;display:none">
						 </dd>
						
				</dl>
				<dl>
					<dt>报名封面：</dt>
					<dd><input type="file" class="file" id='fileName' name='fileName'>
					    <input type="button" class="btn3" value="上传" onclick='uploadImage();'>
					 </dd>
				</dl>
				<dl>
					<dt>封面预览:：</dt>
					<dd>
							<a href='' id='picviewimagehref' target='_blank'>
							<img id="picviewimage" src='http://img3.ddmapimg.com/crm//2013-05-14/233656344.jpg'  width="203" height="135" ></img>
							</a>
					 </dd>
				</dl>
				<dl>
					<dt>活动时间：</dt>
					<dd><input type="text"  name="startDate" id="startDate" class="txt date"  onclick="WdatePicker({dateFmt:'yyyy/MM/dd'})"  value=""> 
					 <!--<select class="select"><option>请选择</option><option>08:00</option><option>09:00</option></select> -->
					 <input type="text" name="endDate" id="endDate" class="txt date"   onclick="WdatePicker({dateFmt:'yyyy/MM/dd'})" value=""> 
					 <!--<select class="select"><option>请选择</option><option>08:00</option><option>09:00</option></select> -->
					 </dd>
				</dl>
				<dl>
					<dt></dt>
					
					<dd>
					<!--	<button class="btn btn2" title="">姓名</button> <button class="btn btn2" title="">性别</button> <button class="btn btn2" title="">电话</button> <button class="btn btn2" title="">快递地址</button> <button class="btn btn2" title="">邮箱</button>
					--> 
						<!--<button class="btn btn2" title="新增选项">+ 新增</button>-->
					</dd>
					
				</dl>
				<dl>
					<dt>活动详情：</dt>
					<dd>&nbsp;</dd>
				</dl>
				<!--
				<dl>
					<dt>报名条件：</dt>
					<dd><select class="select"><option>价格1</option><option>100</option><option>200</option></select> <select class="select"><option>人数上限</option><option>100</option><option>200</option></select> <select class="select"><option>价格2</option><option>100</option><option>200</option></select> <select class="select"><option>人数上限</option><option>100</option><option>200</option></select> <select class="select"><option>价格3</option><option>100</option><option>200</option></select> <select class="select"><option>人数上限</option><option>100</option><option>200</option></select></dd>
				</dl>
				-->
			</div>
			<div class="formContent">
			  	<textarea id="content" name="topicContBeforeFilter" style="height:208px;width:908px"></textarea>
			</div>
			<input type="hidden" name="fkGroupId"  value="${group.groupId?c}">
			<input type="hidden" name="from" id="from" value="/group/detail/${group.groupId?c}">
			<input type="hidden" value="2" name="topicType" id="topicType">
			<input type="hidden" value="1" name="activityType" id="activityType">
			<input type="hidden" value="99" name="fkTitleTypeId" id="fkTitleTypeId">
			<input type="hidden" value="" name="picview" id="picview">
		</div>
		<div class="checkField">
			<!--
			<input type="checkbox" id="shareToWeibo" name="shareTo" class="check" checked><label for="shareToWeibo">同时发布到新浪微博</label>
			<input type="checkbox" id="shareToTencent" name="shareTo" class="check" checked><label for="shareToTencent">同时发布到腾讯微博</label>
			-->
		</div>
		<div class="btnField">
			<input type="button" class="btn btn1" onclick='checkSubmit();' value="" style='width:85px;background:url(${ctx}/images/btn_bg_117.png) 0 0 no-repeat'></button>
		</div>
		</form>
	</div>
	
<#include '/commonFriendLink.ftl'>

</div></section>
<!--主要部分结束-->
<#include '/baseFoot.ftl'>
<script charset="gbk" src="${ctx}/scripts/kindeditor-min.js"></script>
<script src="${ctx}/scripts/ajaxfileupload.js" type="text/javascript"></script>
<script> 
	function uploadImage(){
	    　	 var  fileName = document.getElementById('fileName').value;
	    var allowedExt = ["jpg","jpeg","png","gif","bmp","JPG","JPEG","PNG","GIF","BMP"];
		  if(fileName=="") {
				alert("请选择图片!");
					return;
		}else {
			var ext  = fileName.substring(fileName.lastIndexOf(".")+1);
			var allowed = false;
			for(var index=0;index<allowedExt.length;index++){
				if(allowedExt[index]==ext){
					allowed=true;
					break;
				}
			}
			if(allowed==false){
				alert("请选择图片类型的文件上传");
				retrun;
			}
		}  		
		    
		$.ajaxFileUpload({
				url:"${ctx}/image/uploadimage",
				secureuri:false,
				dataType:'json',
				type:"post",
				fileElementId:"fileName",
				beforeSend:function(){//上传前需要处理的工作，如显示Loading...
		  		},
		  		data:{filename:"fileName"},
				success: function (data, status){
					if(data == 0){
						alert("你选择的图片过大,请重新选择");
						return;
					}
					document.getElementById('picviewimage').src = data.url ;
					document.getElementById('picviewimagehref').href =  data.url ;
					$('#picview').val(data.url);
				},
				error: function (data, status, e){
				}
			});
	}
	function changeType(){
		if ( getCheckedValue("activityTypeRadio") == 1 ){
			$('#point').css("display","none");
		}else{
			$('#point').css("display","");
		}
		
	}
	function calRemain(){
		if ( $('#topicTitleBeforeFilter').val().length > 30 ){
			$('#remain').html("0");
			 $('#topicTitleBeforeFilter').val( $('#topicTitleBeforeFilter').val().substr(0,30) );
		}
		$('#remain').html(30 -   $('#topicTitleBeforeFilter').val().length);
	}
	function checkSubmit(){
		if ( $('#topicTitleBeforeFilter').val()  ==  "" ){
			alert("请输入标题");
			setBorder("topicTitleBeforeFilter");
			 $('#topicTitleBeforeFilter').focus();
			return false ;
		}else{
			clearBorder("topicTitleBeforeFilter");
		}
		if ( $('#topicTitleBeforeFilter').val().length >30){
			alert("标题最多为30 个字符");
			setBorder("topicTitleBeforeFilter");
			return false ;
		}else{
			clearBorder("topicTitleBeforeFilter");
		}
		if ( $('#picview').val() == ''){
			alert("请上传活动封面图");
			return false ;
		}else{
		}
		if ( $('#startDate').val()  == ''){
			alert("请选择开始日期");
			setBorder("startDate");
			return false ;
		}else{
			clearBorder("startDate");
		}
		if ( $('#endDate').val() == ''){
			alert("请选择结束日期");
			setBorder("endDate");
			return false ;
		}else{
			clearBorder("endDate");
		}
		var type = getCheckedValue("activityTypeRadio");
		$('#activityType').val(type);　
		if ( type == 3){
			if (checkInputValue("point","11","number",false,false)){
				if (   $('#point').val().indexOf(".") !=-1){
					alert("消耗正能量不能为小数");
					return ;
				}
				if ( $('#point').val()/1 == 0){
					alert("消耗正能量不能为0");
					return ;
				}
			}else{
				return ;
			}				　　
		}else{
				$('#point').val("0");
		}
		var  content = $('#content').val();
		if ( content.length <  20 ){
			alert('内容不能少于20个字');
			return ;
		}
		document.forms["editorForm"].submit();
	}
	$(function(){
				KE.show({
				id : "content",
				imageUploadJson : '${ctx}/image/uploadimage',
					items : ['source','fontname', 'fontsize', '|', 'undo','redo','plainpaste','wordpaste','|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline','removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist','insertunorderedlist','advtable','hr', '|', 'emoticons', 'image', 'link','|','flash','media'],
				resizeMode : 1,
				allowPreviewEmoticons : true,
				allowUpload : true,
				afterCreate : function(id) {
					KE.event.ctrl(document, 13, function() {
						KE.util.setData(id);
						if(checkSubmit()!=false)
							document.forms["editorForm"].submit();
					});
					KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
						KE.util.setData(id);
						if(checkSubmit()!=false)
							document.forms["editorForm"].submit();
					});
				}
				});
		});
</script>